Allocate the gtk_rc_default_files array dynamically.
authorMatthias Clasen <mclasen@redhat.com>
Mon, 3 Apr 2006 04:17:10 +0000 (04:17 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 3 Apr 2006 04:17:10 +0000 (04:17 +0000)
2006-04-03  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkrc.c (gtk_rc_add_initial_default_files)
(gtk_rc_add_default_file): Allocate the gtk_rc_default_files array
dynamically.

ChangeLog
ChangeLog.pre-2-10
gtk/gtkrc.c

index c450c45b9d3b7d7bca11fbe60cf30611f5a3f12d..b064fdafea65df9ad9662d8b35e8cf05931ec1be 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-03  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_add_initial_default_files) 
+       (gtk_rc_add_default_file): Allocate the gtk_rc_default_files array
+       dynamically.
+
 2006-04-02  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkrc.c: Avoid relocations for the array of symbol names. 
index c450c45b9d3b7d7bca11fbe60cf30611f5a3f12d..b064fdafea65df9ad9662d8b35e8cf05931ec1be 100644 (file)
@@ -1,3 +1,9 @@
+2006-04-03  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_add_initial_default_files) 
+       (gtk_rc_add_default_file): Allocate the gtk_rc_default_files array
+       dynamically.
+
 2006-04-02  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkrc.c: Avoid relocations for the array of symbol names. 
index e62bd3fbed8ca5ea77b8e4795ded8f00acdf16df..69103a16784599841065d3c76bf32632c6b2406b 100644 (file)
@@ -365,8 +365,8 @@ static GHashTable *realized_style_ht = NULL;
 
 static gchar *im_module_file = NULL;
 
-#define GTK_RC_MAX_DEFAULT_FILES 128
-static gchar *gtk_rc_default_files[GTK_RC_MAX_DEFAULT_FILES];
+static gint    max_default_files = 0;
+static gchar **gtk_rc_default_files = NULL;
 
 /* A stack of information of RC files we are parsing currently.
  * The directories for these files are implicitely added to the end of
@@ -493,7 +493,10 @@ gtk_rc_add_initial_default_files (void)
 
   if (init)
     return;
-  
+  gtk_rc_default_files = g_new (gchar*, 10);
+  max_default_files = 10;
+
   gtk_rc_default_files[0] = NULL;
   init = TRUE;
 
@@ -501,7 +504,7 @@ gtk_rc_add_initial_default_files (void)
 
   if (var)
     {
-      files = g_strsplit (var, G_SEARCHPATH_SEPARATOR_S, 128);
+      files = g_strsplit (var, G_SEARCHPATH_SEPARATOR_S, -1);
       i=0;
       while (files[i])
        {
@@ -543,9 +546,17 @@ gtk_rc_add_default_file (const gchar *filename)
   
   gtk_rc_add_initial_default_files ();
 
-  for (n = 0; gtk_rc_default_files[n]; n++) ;
-  if (n >= GTK_RC_MAX_DEFAULT_FILES - 1)
-    return;
+  for (n = 0; n < max_default_files; n++) 
+    {
+      if (gtk_rc_default_files[n] == NULL)
+       break;
+    }
+
+  if (n == max_default_files)
+    {
+      max_default_files += 10;
+      gtk_rc_default_files = g_renew (gchar*, gtk_rc_default_files, max_default_files);
+    }
   
   gtk_rc_default_files[n++] = g_strdup (filename);
   gtk_rc_default_files[n] = NULL;